package com.nexd.location.employee.ui.activity;

import android.annotation.SuppressLint;
import android.widget.TextView;
import android.widget.Toast;

import com.nexd.location.employee.R;
import com.nexd.location.employee.presenter.NexdLocationPresenter;
import com.nexd.location.employee.ui.iView.INexdLocationView;

import butterknife.Bind;

public class NexdLocationActivity extends BaseActivity<NexdLocationPresenter> implements INexdLocationView {

    @Bind(R.id.location_coordinate)
    TextView locationCoordinate;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initPresenter() {
        presenter = new NexdLocationPresenter(this, this);
        presenter.init();
    }

    @Override
    public void initView() {
        presenter.initLocationBuilder();
//        presenter.startLocation();
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void updateLocationCoordinate(final float... locationCoordinate) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                NexdLocationActivity.this.locationCoordinate.setText(
                        "X:" + locationCoordinate[0] + "\n" + "y:" + locationCoordinate[1]);
            }
        });
    }

    @Override
    public void showToast(final String msg) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(NexdLocationActivity.this, msg, Toast.LENGTH_SHORT).show();
            }
        });
    }
}
